home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE22
/
EX13.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
4KB
|
89 lines
#include <genstub.c>
// Flags on bottom of table.
#define LEGEND1 "ANSI character set flags. 1=Lower, 2=Upper, 4=Digit, 8=SPACE"
#define LEGEND2 " 10=Punctuation, 20=Control, 40=Blank, 80=Hex"
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
int i, j;
HFONT hOldFont;
TCHAR szTemp[128];
TCHAR szBuffer[128];
TCHAR szLittleBuffer[17];
WORD wTypeArray[16];
HDC hDC = GetDC( hWnd );
hOldFont = SelectObject( hDC, GetStockObject(
ANSI_FIXED_FONT ) );
szTemp[0]=0;
for ( j=0; j<16; j++ )
{
wsprintf( szBuffer, "%X ", j );
lstrcat( szTemp, szBuffer );
}
lstrcpy( szBuffer, szTemp );
lstrcat( szTemp, " ");
for ( j=0; j<16; j++ )
{
wsprintf( szBuffer, "%X ", j );
lstrcat( szTemp, szBuffer );
}
TextOut(hDC, 22, 0, szTemp, lstrlen(szTemp) );
for ( i=0; i<16; i++ )
{
wsprintf( szTemp, "%2X ", i*16 );
szLittleBuffer[0] = 0;
for ( j=0; j<16; j++ )
{
if (i==0 && j==0)
lstrcpy( szBuffer, " " );
else
wsprintf( szBuffer, "%c", j+i*16 );
lstrcat( szLittleBuffer, szBuffer );
lstrcat( szTemp, szBuffer );
lstrcat( szTemp, " " );
}
GetStringTypeA( LOCALE_USER_DEFAULT,CT_CTYPE1,
szLittleBuffer, 16, &wTypeArray );
for ( j=0; j<16; j++ )
{
wsprintf( szBuffer, "%2X", (BYTE)wTypeArray[j] );
lstrcat( szTemp, szBuffer );
}
TextOut( hDC, 0, (i + 1)*15, szTemp,
lstrlen( szTemp ) );
}
TextOut( hDC, 60, 256, LEGEND1, lstrlen( LEGEND1 ) );
TextOut( hDC, 60, 272, LEGEND2, lstrlen( LEGEND2 ) );
TextOut( hDC, 60, 272, szBuffer, lstrlen(szBuffer) );
DeleteObject( SelectObject( hDC, hOldFont ) );
ReleaseDC( hWnd, hDC );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
}
return( NULL );
}